package com.migo.controller;

import com.migo.entity.UserDeviceRegisterEntity;
import com.migo.service.UserDeviceRegisterService;
import com.migo.utils.PageUtils;
import com.migo.utils.Query;
import com.migo.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 用户注册设备记录表
 * 
 * @author powervision
 * @email wes.wang@powervision.me
 * @date 2020-08-19 15:50:58
 */
@RestController
@RequestMapping("userdeviceregister")
public class UserDeviceRegisterController {
	@Autowired
	private UserDeviceRegisterService userDeviceRegisterService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("userdeviceregister:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<UserDeviceRegisterEntity> userDeviceRegisterList = userDeviceRegisterService.queryList(query);
		int total = userDeviceRegisterService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(userDeviceRegisterList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("userdeviceregister:info")
	public R info(@PathVariable("id") Integer id){
		UserDeviceRegisterEntity userDeviceRegister = userDeviceRegisterService.queryObject(id);
		
		return R.ok().put("userDeviceRegister", userDeviceRegister);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("userdeviceregister:save")
	public R save(@RequestBody UserDeviceRegisterEntity userDeviceRegister){
		userDeviceRegisterService.save(userDeviceRegister);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("userdeviceregister:update")
	public R update(@RequestBody UserDeviceRegisterEntity userDeviceRegister){
		userDeviceRegisterService.update(userDeviceRegister);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("userdeviceregister:delete")
	public R delete(@RequestBody Integer[] ids){
		userDeviceRegisterService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
